// ==================== src/traits/config_service.rs ====================
//! 配置服务trait

use async_trait::async_trait;
use crate::{Result, ConfigItem, EventListener};

/// 配置服务trait
#[async_trait]
pub trait ConfigService: Send + Sync + std::fmt::Debug {
    /// 获取配置
    async fn get_config(&self, namespace: &str, group: &str, data_id: &str) -> Result<Option<String>>;
    
    /// 发布配置
    async fn publish_config(&self, namespace: &str, group: &str, data_id: &str, content: &str) -> Result<bool>;
    
    /// 删除配置
    async fn remove_config(&self, namespace: &str, group: &str, data_id: &str) -> Result<bool>;
    
    /// 获取配置详情
    async fn get_config_detail(&self, namespace: &str, group: &str, data_id: &str) -> Result<Option<ConfigItem>>;
    
    /// 获取配置列表
    async fn list_configs(&self, namespace: &str, group: Option<&str>) -> Result<Vec<ConfigItem>>;
    
    /// 添加配置监听器
    async fn add_listener(&self, namespace: &str, group: &str, data_id: &str, listener: Box<dyn EventListener>) -> Result<()>;
    
    /// 移除配置监听器
    async fn remove_listener(&self, namespace: &str, group: &str, data_id: &str, listener_name: &str) -> Result<()>;
    
    /// 获取配置的MD5值
    async fn get_config_md5(&self, namespace: &str, group: &str, data_id: &str) -> Result<Option<String>>;
}